[id].vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. <template>
  2. <div>
  3. <!-- 页面头部 -->
  4. <!-- <HomePageHead></HomePageHead>
  5. <HomePageNavigation1></HomePageNavigation1> -->
  6. <!-- 头部 -->
  7. <templateHead></templateHead>
  8. <!-- 菜单 -->
  9. <templateMenu></templateMenu>
  10. <!-- 商圈详情 -->
  11. <div class="topicInfoBox">
  12. <div class="inner">
  13. <!-- 详情头部 -->
  14. <div class="infoHead">
  15. <div class="left">
  16. <div class="userInfo left">
  17. <el-badge value="楼主" class="item" type="warning">
  18. <img v-if='dataInfo.avatar' :src="dataInfo.avatar" alt="">
  19. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png' alt="">
  20. </el-badge>
  21. <span>{{ dataInfo.author }}</span>
  22. </div>
  23. <div class="headContent left">
  24. <h2>{{ dataInfo.title }}</h2>
  25. <p v-show="dataInfo.group_name">
  26. 群聊:
  27. <span>{{ dataInfo.group_name }}</span>
  28. <button @click="joinGroup">加入群聊</button>
  29. </p>
  30. </div>
  31. </div>
  32. <div class="right">
  33. <div class="one">
  34. <span v-for="item in typeList" :key="index">
  35. <span v-if="dataInfo.type == item.value" class="one">{{item.label}}</span>
  36. </span>
  37. </div>
  38. <p>{{ dataInfo.updated_at }}</p>
  39. </div>
  40. </div>
  41. <!-- 详情页 文本+图片 -->
  42. <div class="infoContent" v-show="dataInfo.content">
  43. <div v-html="dataInfo.content"></div>
  44. </div>
  45. <div class="infoContent1" v-show="!dataInfo.content">
  46. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Document_empty.png" alt="">
  47. <span>可以看看大家的互动哦~</span>
  48. </div>
  49. <!-- 详情页评论 -->
  50. <div class="comment">
  51. <h3>评论</h3>
  52. <div class="commentList" v-for="item in replyList" v-show="page_total != 0">
  53. <div class="left">
  54. <img v-if='item.avatar' :src="item.avatar" alt="" >
  55. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png' alt="">
  56. <span class="name">{{ item.nickname }} : </span>
  57. </div>
  58. <div class="center">
  59. <span class="context">{{ item.content }}</span>
  60. </div>
  61. <div class="right">
  62. <span class="time">{{ item.created_at }}</span>
  63. <!-- <span>回复</span> -->
  64. </div>
  65. </div>
  66. <div class="comment_empty" v-show="page_total == 0">
  67. <img src="../../public/topic/message_empty.png" alt="">
  68. <span>暂无评论</span>
  69. </div>
  70. </div>
  71. <!-- 分页 -->
  72. <div class="paginationBox" v-show="page_total != 0">
  73. <el-pagination background layout="prev, pager, next" :total="page_total" prev-text="上一页"
  74. next-text="下一页" :default-page-size="pageSize" @change="changePage" />
  75. </div>
  76. </div>
  77. </div>
  78. <div class="message">
  79. <div class="inner">
  80. <input v-model="content" placeholder="快来回复吧~" type="text" class="messageInput">
  81. <button class="btn" @click="addReply">确定</button>
  82. </div>
  83. </div>
  84. <!-- 页面底部 -->
  85. <!-- <HomeFoot></HomeFoot> -->
  86. <templateFoot></templateFoot>
  87. </div>
  88. </template>
  89. <script setup>
  90. //1.引用模块 start ---------------------------------------->
  91. //使用ref和reactive动态变量
  92. import { ref, reactive, onMounted } from 'vue'
  93. import { useRoute } from 'vue-router';
  94. //使用官方ssr请求模块
  95. import { useNuxtApp, useFetch } from '#app'
  96. //使用element-plus组件
  97. import { ElPagination, ElBadge, ElInput, ElMessage, ElMessageBox } from 'element-plus';
  98. // axios请求
  99. const nuxtApp = useNuxtApp();
  100. const axios = nuxtApp.$axios;
  101. const { $webUrl, $CwebUrl, $BwebUrl } = useNuxtApp()
  102. //1.引用模块 end ---------------------------------------->
  103. // 定义响应式数据
  104. const seoData = ref({
  105. title: '商圈',
  106. description: '默认描述',
  107. keywords: '默认关键词',
  108. image: 'https://example.com/default-image.jpg'
  109. });
  110. // 在 onMounted 钩子中获取数据
  111. onMounted(()=>{
  112. seoData.value.title = '商圈';
  113. seoData.value.description = '默认描述';
  114. seoData.value.keywords = '默认关键词';
  115. })
  116. //2.页面数据 start ---------------------------------------->
  117. const dataInfo = ref({})
  118. const groupId = useState("groupId", () => '')
  119. const replyList = useState("replyList", () => []) //评论列表
  120. //分页
  121. const page = ref(1)
  122. const pageSize = ref(5)
  123. let page_total = ref(0)
  124. const content = ref('')
  125. //2.页面数据 end ---------------------------------------->
  126. //3.获取商圈详情 start ---------------------------------------->
  127. const route = useRoute();
  128. const id = route.params.id; // 获取传递的 id 参数
  129. //页码发生改变
  130. const changePage = (val) => {
  131. console.log(val);
  132. page.value = val
  133. getTopicReply()
  134. }
  135. // 商圈信息
  136. const getTopicInfo = () => {
  137. let data = new FormData()
  138. data.append('id', id)
  139. axios.post('chat/getTopicInfo', data).then(res => {
  140. console.log('商圈信息', res);
  141. dataInfo.value = res.data
  142. groupId.value = res.data.group_id
  143. console.log(groupId.value);
  144. })
  145. }
  146. // 回复商圈 列表
  147. const getTopicReply = () => {
  148. let data = new FormData()
  149. data.append('id', id)
  150. data.append('page', page.value)
  151. data.append('page_size', pageSize.value)
  152. axios.post('chat/getTopicReply', data).then(res => {
  153. console.log('回复商圈列表 ', res);
  154. replyList.value = res.data.data
  155. // page_total.value = res.data.total
  156. page_total.value = res.data.total
  157. console.log("replyList", replyList);
  158. })
  159. }
  160. //5.获取分类和状态 start ---------------------------------------->
  161. const listData = useState("listData", () => [])//商圈列表
  162. const typeList = useState("typeList", () => [])//商圈分类
  163. const topicType = () => {
  164. axios.post('/chat/topicType').then(response => {
  165. console.log(111222333)
  166. console.log(response.data);
  167. // console.log(1);
  168. typeList.value = response.data;
  169. })
  170. }
  171. const topicStatus = () => {
  172. axios.post('chat/topicStatus').then(response => {
  173. console.log(response);
  174. })
  175. }
  176. onMounted(() => {
  177. getTopicInfo(); //商圈信息
  178. getTopicReply(); //回复商圈列表
  179. topicType();
  180. topicStatus();
  181. })
  182. //加入群聊
  183. const joinGroup = () => {
  184. ElMessageBox.confirm(
  185. '加入群聊后,页面跳转至后台群聊页面',
  186. '是否加入群聊?',
  187. {
  188. confirmButtonText: '是',
  189. cancelButtonText: '否',
  190. center: true,
  191. }
  192. ).then(() => {
  193. console.log('groupId.value', groupId.value);
  194. let data = new FormData()
  195. data.append('group_id', groupId.value)
  196. axios.post('chat/joinGroup', data).then(res => {
  197. console.log('加入群聊 ', res);
  198. if (res.code == 0 && res.message !== '已加入群') {
  199. ElMessage.error(res.message)
  200. } else if (res.code == 0 && res.message == '已加入群') {
  201. ElMessage({
  202. message: res.message,
  203. type: 'success',
  204. })
  205. setTimeout(() => {
  206. window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  207. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  208. }, 1000)
  209. } else if (res.code == 200) {
  210. ElMessage({
  211. message: '加入成功',
  212. type: 'success',
  213. })
  214. setTimeout(() => {
  215. window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  216. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  217. }, 1000)
  218. }
  219. })
  220. }).catch(() => {
  221. ElMessage({
  222. type: 'error',
  223. message: '已取消',
  224. })
  225. })
  226. }
  227. // 回复商圈
  228. const addReply = () => {
  229. let data = new FormData()
  230. data.append('id', id)
  231. data.append('content', content.value)
  232. axios.post('chat/addReply', data).then(res => {
  233. console.log('回复商圈 ', res);
  234. if (res.code == 0) {
  235. ElMessage.error(res.message)
  236. getTopicReply();
  237. } else if (res.code == 200) {
  238. ElMessage({
  239. message: '回复成功',
  240. type: 'success',
  241. })
  242. content.value = ''
  243. getTopicReply();
  244. }
  245. })
  246. }
  247. //3.获取商圈详情 end ---------------------------------------->
  248. //自助建站 start---------------------------------------->
  249. //1.获得自助建站头部底部
  250. import templateHead from '@/components/template/sector/head/1200x200/1.vue'
  251. import templateMenu from '@/components/template/sector/menu/1200x130/1.vue'
  252. import templateFoot from '@/components/template/sector/foot/1200x580/1.vue'
  253. //2.获得pinia源
  254. import { useTemplateBaseStore } from '@/stores/templateBase'
  255. const templateBaseStore = useTemplateBaseStore()
  256. //3.获得该页的皮肤id
  257. const skinId = ref("")
  258. //4.获得站点基本信息
  259. const responseStatus = await requestDataPromise('/web/getWebsiteAllinfo', {
  260. method: 'GET',
  261. query: {
  262. 'link_textnum':24,
  263. 'link_imgnum':18,
  264. 'link_footnum':4
  265. },
  266. });
  267. if (responseStatus.code == 200) {
  268. //4.1设置站点基本信息
  269. templateBaseStore.setWebSiteInfo(responseStatus.data)
  270. //4.2设置皮肤id
  271. skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
  272. //4.3设置seo
  273. useSeoMeta({
  274. title: "商圈" + "_" + "三农资讯网_全国政务信息一体化应用平台",
  275. meta: [
  276. { name: 'description', content: "三农资讯网以服务于党和国家各级职能部门三农政务资讯发布及政务公开信息公示为基点,为全国县级以上各级党政机关及其职能部门配置各自公开独立网络发布平台。主要频道有:三农政务资讯,农科资讯,农资购销,农产购销,农贸资讯,三农致富信息,农村文化生活,三农政策法规,三农之窗,三农调查,三农服务,三农知识,农民工,打假维权等。三农资讯网打造最具影响力的三农信息发布平台,并成为最具权威的三农资讯网。_三农资讯网-测试专用_全国政务信息一体化应用平台" , tagPriority: 10 },
  277. { name: 'keywords', content: "三农资讯,农业,三农,三农在线,农业新闻,三农资讯网_三农资讯网-测试专用_全国政务信息一体化应用平台" , tagPriority: 10 }
  278. ]
  279. });
  280. }
  281. //5.获得广告池
  282. const adData = ref([]);
  283. const adResponseStatus = await requestDataPromise('/web/getWebsiteAdvertisement', {
  284. method: 'GET',
  285. query: {},
  286. });
  287. if (adResponseStatus.code == 200) {
  288. templateBaseStore.setAdList(adResponseStatus.data)
  289. adData.value = adResponseStatus.data;
  290. }
  291. //自助建站 end---------------------------------------->
  292. </script>
  293. <style lang="less" scoped>
  294. .topicInfoBox {
  295. .inner {
  296. width: 1200px;
  297. margin: 0 auto;
  298. //信息头部
  299. .infoHead {
  300. height: 175px;
  301. padding: 30px 0 60px 40px;
  302. border-bottom: 1px solid rgba(0, 0, 0, 0.10);
  303. box-sizing: border-box;
  304. >.left {
  305. .userInfo {
  306. margin-right: 90px;
  307. .item {
  308. margin-top: -5px;
  309. margin-right: -5px;
  310. :deep(.el-badge__content.is-fixed) {
  311. position: absolute;
  312. right: calc(1px + var(--el-badge-size) / 2);
  313. top: 0;
  314. transform: translateY(-31%) translateX(79%);
  315. z-index: var(--el-index-normal);
  316. }
  317. img {
  318. width: 66px;
  319. height: 66px;
  320. vertical-align: middle;
  321. border-radius: 50%;
  322. }
  323. }
  324. span {
  325. margin-left: 15px;
  326. font-family: Microsoft YaHei, Microsoft YaHei;
  327. font-weight: 400;
  328. font-size: 18px;
  329. color: #333333;
  330. }
  331. }
  332. .headContent {
  333. h2 {
  334. width: 750px;
  335. height: 56px;
  336. line-height: 28px;
  337. display: -webkit-box;
  338. -webkit-box-orient: vertical;
  339. -webkit-line-clamp: 2;
  340. overflow: hidden;
  341. text-overflow: ellipsis;
  342. word-break: break-all;
  343. font-family: Microsoft YaHei, Microsoft YaHei;
  344. font-weight: bold;
  345. font-size: 20px;
  346. color: #333333;
  347. margin-bottom: 26px;
  348. }
  349. >p {
  350. font-family: Microsoft YaHei, Microsoft YaHei;
  351. font-weight: 400;
  352. font-size: 16px;
  353. color: #333333;
  354. button {
  355. width: 86px;
  356. height: 32px;
  357. background-color: #028e21;
  358. color: #fff;
  359. border: none;
  360. margin-left: 100px;
  361. }
  362. }
  363. }
  364. }
  365. >.right {
  366. position: relative;
  367. div {
  368. position: absolute;
  369. right: 0;
  370. top: 0;
  371. width: 71px;
  372. height: 32px;
  373. line-height: 32px;
  374. text-align: center;
  375. background-color: #d9f0d6;
  376. margin-bottom: 29px;
  377. font-family: Microsoft YaHei, Microsoft YaHei;
  378. font-weight: 400;
  379. font-size: 16px;
  380. color: #33B023;
  381. }
  382. .one {
  383. color: #FFAA33;
  384. background-color: #fbebd5;
  385. }
  386. .two {
  387. color: #33B023;
  388. background-color: #d5ecd2;
  389. }
  390. .three {
  391. color: #666;
  392. background-color: #ebebeb;
  393. }
  394. p {
  395. width: 150px;
  396. text-align: right;
  397. position: absolute;
  398. top: 62px;
  399. right: 0;
  400. }
  401. }
  402. }
  403. // 有详情信息
  404. .infoContent {
  405. width:1196px;
  406. overflow: hidden;
  407. padding: 40px 46px;
  408. font-family: Microsoft YaHei, Microsoft YaHei;
  409. font-size: 20px;
  410. line-height: 40px;
  411. box-sizing: border-box;
  412. div{
  413. word-wrap: break-word; /* 强制长单词或 URL 换行 */
  414. overflow-wrap: break-word; /* 现代推荐用法,等同于 word-wrap */
  415. white-space: pre-wrap; /* 保留空白字符并允许自动换行 */
  416. word-break: break-all; /* 强制在任意字符处换行 */
  417. }
  418. }
  419. .leftBottom::v-deep p{
  420. width:1200px;
  421. white-space: pre-wrap;
  422. }
  423. //没有详情信息
  424. .comment_empty,
  425. .infoContent1 {
  426. height: 300px;
  427. line-height: 260px;
  428. text-align: center;
  429. img {
  430. width: 78px;
  431. height: 78px;
  432. vertical-align: -25px;
  433. vertical-align: middle;
  434. margin-right: 20px;
  435. }
  436. span {
  437. font-family: Microsoft YaHei, Microsoft YaHei;
  438. font-weight: bold;
  439. font-size: 26px;
  440. color: #CCCCCC;
  441. }
  442. }
  443. //评论
  444. .comment {
  445. h3 {
  446. height: 100px;
  447. padding-top: 30px;
  448. box-sizing: border-box;
  449. border-bottom: 1px solid #E1E1E1;
  450. font-family: Microsoft YaHei, Microsoft YaHei;
  451. font-weight: 400;
  452. font-size: 22px;
  453. color: #000000;
  454. }
  455. .commentList {
  456. // height: 112px;
  457. border: 1px solid #E1E1E1;
  458. background-color: #fafafa;
  459. margin-top: 20px;
  460. padding: 30px 30px;
  461. box-sizing: border-box;
  462. display: flex;
  463. align-items: flex-start;
  464. justify-content: space-between;
  465. .left {
  466. width:400px;
  467. margin-right: 40px;
  468. // overflow: hidden;
  469. display: flex;
  470. justify-content: space-between;
  471. img {
  472. // float: left;
  473. width: 52px;
  474. height: 52px;
  475. border-radius: 50%;
  476. vertical-align: middle;
  477. margin-right: 15px;
  478. }
  479. span{
  480. // float: left;
  481. height: 52px;
  482. line-height: 22px;
  483. padding-top: 14px;
  484. }
  485. .name {
  486. width: 100px;
  487. font-family: Microsoft YaHei, Microsoft YaHei;
  488. font-weight: 400;
  489. font-size: 16px;
  490. color: #333333;
  491. margin-right: 30px;
  492. width: 100px;
  493. white-space: nowrap;
  494. overflow: hidden;
  495. text-overflow: ellipsis;
  496. display: block;
  497. }
  498. }
  499. .center {
  500. .context {
  501. width: 700px;
  502. margin-right: 40px;
  503. display: -webkit-box;
  504. -webkit-box-orient: vertical;
  505. -webkit-line-clamp: 2;
  506. overflow: hidden;
  507. text-overflow: ellipsis;
  508. word-break: break-all;
  509. font-family: Microsoft YaHei, Microsoft YaHei;
  510. font-weight: bold;
  511. font-size: 16px;
  512. color: #333333;
  513. padding-top: 14px;
  514. }
  515. }
  516. .right {
  517. padding-top: 12px;
  518. .time {
  519. display: block;
  520. width: 200px;
  521. font-family: Microsoft YaHei, Microsoft YaHei;
  522. font-weight: 400;
  523. font-size: 16px;
  524. color: #999999;
  525. margin-right: 30px;
  526. }
  527. span {
  528. font-family: Microsoft YaHei, Microsoft YaHei;
  529. font-weight: 400;
  530. font-size: 16px;
  531. color: #333333;
  532. }
  533. }
  534. }
  535. // .comment_empty {
  536. // height: 200px;
  537. // line-height: 200px;
  538. // text-align: center;
  539. // img {
  540. // width: 78px;
  541. // height: 78px;
  542. // vertical-align: -25px;
  543. // margin-right: 20px;
  544. // }
  545. // span {
  546. // font-family: Microsoft YaHei, Microsoft YaHei;
  547. // font-weight: bold;
  548. // font-size: 26px;
  549. // color: #CCCCCC;
  550. // }
  551. // }
  552. }
  553. }
  554. }
  555. //评论回复
  556. .message {
  557. width: 1200px;
  558. margin: 0 auto;
  559. padding: 0px 25px;
  560. box-sizing: border-box;
  561. height: 145px;
  562. line-height: 145px;
  563. background-color: #ecf5ee;
  564. margin-bottom: 30px;
  565. .inner {
  566. .messageInput {
  567. width: 1000px;
  568. height: 67px;
  569. outline: none;
  570. border: 1px solid #E1E1E1;
  571. background-color: #fafafa;
  572. font-family: Microsoft YaHei, Microsoft YaHei;
  573. font-weight: 400;
  574. font-size: 18px;
  575. color: #666;
  576. padding: 0 20px;
  577. box-sizing: border-box;
  578. }
  579. .btn {
  580. width: 115px;
  581. height: 40px;
  582. border: none;
  583. background-color: #028e21;
  584. color: #fff;
  585. border-radius: 6px;
  586. margin-left: 36px;
  587. font-family: Microsoft YaHei, Microsoft YaHei;
  588. font-weight: 400;
  589. font-size: 16px;
  590. }
  591. }
  592. }
  593. //分页
  594. .paginationBox {
  595. display: flex;
  596. justify-content: center;
  597. margin-top: 60px;
  598. margin-bottom: 60px;
  599. // 鼠标移入后字体颜色
  600. :deep(.el-pagination:hover) {
  601. color: #139609;
  602. }
  603. :deep(.el-pagination.is-background .btn-next),
  604. :deep(.el-pagination.is-background .btn-prev) {
  605. width: 70px;
  606. height: 34px;
  607. margin: 0px 10px;
  608. border-radius: 4px;
  609. }
  610. :deep(.el-pagination.is-background .el-pager li) {
  611. margin: 0px 10px;
  612. width: 38px;
  613. height: 34px;
  614. border-radius: 4px;
  615. }
  616. :deep(.el-pagination.is-background .btn-next.is-active),
  617. :deep(.el-pagination.is-background .btn-prev.is-active),
  618. :deep(.el-pagination.is-background .el-pager li.is-active) {
  619. background-color: #028e21;
  620. color: #fff;
  621. }
  622. }
  623. </style>